package com.chixing.ih.module.programmer.mapper;

import com.chixing.ih.common.IhRepository;
import com.chixing.ih.module.programmer.mapper.provider.AttentionMapperProvider;
import com.chixing.ih.module.programmer.pojo.Attention;
import com.chixing.ih.module.programmer.pojo.dto.AttentionDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-09-30
 * Time: 13:25
 *
 * @version 1.0
 */
@Mapper
public interface AttentionMapper extends IhRepository<Attention> {

    @SelectProvider(type = AttentionMapperProvider.class, method = "listFollower")
    @Results(id = "attentionMap", value = {
            @Result(id = true, column = "id", property = "attention.id"),
            @Result(column = "follower_id", property = "attention.followerId"),
            @Result(column = "followed_id", property = "attention.followedId"),
            @Result(column = "followed_time", property = "attention.followedTime"),
            @Result(column = "follow_status", property = "attention.followStatus")
    })
    List<AttentionDTO> listFollower(long followerId);


    @SelectProvider(type = AttentionMapperProvider.class, method = "listFan")
    @ResultMap("attentionMap")
    List<AttentionDTO> listFan(long followedId);


    @SelectProvider(type = AttentionMapperProvider.class, method = "getStatus")
    Integer getStatus(Attention attention);


    @InsertProvider(type = AttentionMapperProvider.class, method = "insertOne")
    int insertOne(Attention attention);


    @DeleteProvider(type = AttentionMapperProvider.class, method = "deleteOne")
    int deleteOne(@Param("followerId") long followerId, @Param("followedId") long followedId);

    @SelectProvider(type = AttentionMapperProvider.class, method = "followerNum")
    Long followerNum(long followerId);

    @SelectProvider(type = AttentionMapperProvider.class, method = "fanNum")
    Long fanNum(long followedId);


}
